import 'package:flutter/material.dart';
import 'package:flutter_kit_plus/flutter_kit.dart';

import '../../class/dialog/commont/diaButton.dart';

class UploadView extends BaseDialog {
  void Function()? onOk;
  UploadView({super.key});

  @override
  BaseDialogState createState() => _UploadViewState();
}

class _UploadViewState extends BaseDialogState<UploadView> {
  final _textControlller = TextEditingController();
  @override
  void initState() {
    super.initState();
    _textControlller.text = '';
    _textControlller.addListener(() {
      String text = _textControlller.text;
    });
  }

  void function(String text) async {
    switch (text) {
      case 'OK':
        Navigator.pop(context);
        if (widget.onOk != null) {
          widget.onOk!();
        }
      case 'Cancel':
        Navigator.pop(context);

      default:
    }
  }

  @override
  Widget buildContent(BuildContext context) {
    return LayoutBuilder(builder: (BuildContext context, BoxConstraints constrains) {
      return Container(
        height: 150,
        child: Stack(
          children: [
            ///标题
            const Positioned(
                left: 10,
                right: 30,
                top: 20,
                height: 60,
                child: Text(
                  'Please confirm to upload current device DSP data?\n It takes one minute to upload',
                  textAlign: TextAlign.left,
                  style: TextStyle(fontSize: 14, color: Colors.black),
                )),

            Positioned(
              left: 10,
              right: 10,
              top: 80,
              height: 30,
              child: Container(),
            ),

            Positioned(
              left: 10,
              right: 10,
              top: 109,
              child: Container(color: Colors.black, height: 0.5),
            ),

            Positioned(
                right: 0,
                top: 110,
                height: 40,
                width: 60,
                child: Diabutton(title: 'OK', onClick: () => function('OK'))),

            Positioned(
                right: 60,
                top: 110,
                height: 40,
                width: 70,
                child: Diabutton(title: 'Cancel', onClick: () => function('Cancel'))),
          ],
        ),
      );
    });
  }
}
